<?php
namespace store\fastdfs;

use Eelly\FastDFS\Client;
use utils\ConfigReader;
use store\FileBlockReader;
use store\StorageType;
/*
	文件块数据读取类
	修改FastDFS/Client.php
		public function readFile($id,$offset,$size){
			list($groupName, $filePath) = explode('/', $id, 2);
			return $this->getStorage($groupName)->readFile($groupName, $filePath,$offset,$size);
		}
	更新记录：
        2022-05-16 创建
*/
class FastDFSReader extends FileBlockReader
{
	function __construct() 
	{
	    $this->storage = StorageType::FastDFS;
	}

	/**
	 * 读取数据
	 * @param string $id
	 * @param int64 $offset
	 * @param int $size
	 * @return string
	 */
	function read($id,$offset=0,$size=0)
	{
		$client = new Client(ConfigReader::fastDFSConfig());
        return $client->readFile($id,$offset,$size);
	}
}
?>